package io.xuan.modules.app.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.xuan.modules.app.dao.EvaluateDao;
import io.xuan.modules.app.entity.EvaluateEntity;
import io.xuan.modules.app.service.EvaluateService;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("evaluateServiceImpl")
public class EvaluateServiceImpl extends ServiceImpl<EvaluateDao, EvaluateEntity>
        implements EvaluateService {


    @Override
    public List<EvaluateEntity> queryByUserId(Long userId) {
        LambdaQueryWrapper<EvaluateEntity> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(EvaluateEntity::getUid, userId);
        return this.list(queryWrapper);
    }

    @Override
    public List<EvaluateEntity> allEvaluate() {
        return this.list();
    }

    @Override
    public List<EvaluateEntity> queryByDriverId(Long userId) {
        LambdaQueryWrapper<EvaluateEntity> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(EvaluateEntity::getDriverId, userId);
        return this.list(queryWrapper);
    }

    @Override
    public boolean saveEvaluate(EvaluateEntity evaluate) {
        return this.save(evaluate);
    }

}
